package com.chatdating.controller;

import com.chatdating.entity.dto.MatchDto;
import com.chatdating.entity.pojo.Result;
import com.chatdating.service.LikeUserService;
import com.chatdating.utils.EmptyUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("likeUser")
public class LikeUserController {
    @Autowired
    private LikeUserService likeUserService;

    @PostMapping("findAllLikeUser")
    public Result findAllLikeUser(Integer userId) {
        if(EmptyUtil.isEmpty(userId)) {
            return Result.error(400,"未获取到用户Id");
        }else{
            List<MatchDto> matchDtoList = likeUserService.findAllLikeUser(userId);
            return Result.success(matchDtoList);
        }

    }

    @PostMapping("deleteLikeUser")
    public Result deleteLikeUser(Integer userId, Integer noLikeUserId) {
        if(EmptyUtil.isEmpty(userId)) {
            return Result.error(400,"未获取到用户Id");
        }else{
            likeUserService.deleteLikeUser(userId,noLikeUserId);
            return Result.success("删除成功");
        }
    }


    @PostMapping("addLikeUser")
    public Result addLikeUser(Integer userId, Integer likeUserId) {
        if(EmptyUtil.isEmpty(userId)) {
            return Result.error(400,"未获取到用户Id");
        }else{
            likeUserService.addLikeUser(userId,likeUserId);
            return Result.success("添加成功");
        }

    }
}
